﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Controls;
using CoiffeurProject.Utils;

namespace CoiffeurProject.UserControls
{
    #region AgendaPage

    internal class AgendaPage
    {
        Grid main_container;
        Image right, left;
        Button right_btn, left_btn;

        internal AgendaPage(int gridRow, int gridColumn)
        {
            InitializeMainContainer();
            InitializeInternalComponents();

            Grid.SetRow(main_container, gridRow);
            Grid.SetColumn(main_container, gridColumn);
        }

        private void InitializeMainContainer()
        {
            main_container = new Grid();
            main_container.Width = 280;
            main_container.Height = 466;
            main_container.Margin = new Thickness(0);
            main_container.HorizontalAlignment = HorizontalAlignment.Center;
            main_container.VerticalAlignment = VerticalAlignment.Center;
            main_container.Background = new ImageBrush(new BitmapImage(
                new Uri(ImagesPath.AgendaPage)));

            main_container.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50) });
            main_container.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(117) });
            main_container.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(158) });
            main_container.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });

            main_container.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(140) });
            main_container.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(140) });
        }

        private void InitializeInternalComponents()
        {
            right = new Image();
            right.Source = new BitmapImage(new Uri(ImagesPath.PressedTicket));
            right.Width = 115;
            right.Height = 113;
            right.VerticalAlignment = VerticalAlignment.Top;
            right.HorizontalAlignment = HorizontalAlignment.Right;
            right.Margin = new Thickness(0, 10, 10, 0);
            right.Visibility = Visibility.Hidden;
            right.IsHitTestVisible = false;

            main_container.Children.Add(right);
            Grid.SetRow(right, 3);
            Grid.SetColumn(right, 1);

            left = new Image();
            left.Source = new BitmapImage(new Uri(ImagesPath.PressedTicket));
            left.Width = 115;
            left.Height = 113;
            left.VerticalAlignment = VerticalAlignment.Top;
            left.HorizontalAlignment = HorizontalAlignment.Left;
            left.Margin = new Thickness(10, 10, 0, 0);
            left.Visibility = Visibility.Hidden;
            left.IsHitTestVisible = false;

            main_container.Children.Add(left);
            Grid.SetRow(left, 3);
            Grid.SetColumn(left, 0);

            right_btn = new Button();
            right_btn.SetResourceReference(Button.StyleProperty, "NoChromeButton");
            right_btn.Width = 120;
            right_btn.Height = 120;
            right_btn.HorizontalAlignment = HorizontalAlignment.Center;
            right_btn.VerticalAlignment = VerticalAlignment.Center;
            right_btn.Content = new Image();
            (right_btn.Content as Image).Stretch = Stretch.Fill;
            (right_btn.Content as Image).Source = new BitmapImage(new Uri(ImagesPath.Blank));
            right_btn.Click += new RoutedEventHandler(right_btn_Click);
            right_btn.MouseEnter += new MouseEventHandler(right_btn_MouseEnter);
            right_btn.MouseLeave += new MouseEventHandler(right_btn_MouseLeave);

            main_container.Children.Add(right_btn);
            Grid.SetRow(right_btn, 3);
            Grid.SetColumn(right_btn, 1);

            left_btn = new Button();
            left_btn.SetResourceReference(Button.StyleProperty, "NoChromeButton");
            left_btn.Width = 120;
            left_btn.Height = 120;
            left_btn.HorizontalAlignment = HorizontalAlignment.Center;
            left_btn.VerticalAlignment = VerticalAlignment.Center;
            left_btn.Content = new Image();
            (left_btn.Content as Image).Stretch = Stretch.Fill;
            (left_btn.Content as Image).Source = new BitmapImage(new Uri(ImagesPath.Blank));
            left_btn.Click += new RoutedEventHandler(left_btn_Click);
            left_btn.MouseEnter += new MouseEventHandler(left_btn_MouseEnter);
            left_btn.MouseLeave += new MouseEventHandler(left_btn_MouseLeave);

            main_container.Children.Add(left_btn);
            Grid.SetRow(left_btn, 3);
            Grid.SetColumn(left_btn, 0);
        }

        void left_btn_MouseLeave(object sender, MouseEventArgs e)
        {
            left.Visibility = Visibility.Hidden;
        }

        void left_btn_MouseEnter(object sender, MouseEventArgs e)
        {
            left.Visibility = Visibility.Visible;
        }

        void right_btn_MouseLeave(object sender, MouseEventArgs e)
        {
            right.Visibility = Visibility.Hidden;
        }

        void right_btn_MouseEnter(object sender, MouseEventArgs e)
        {
            right.Visibility = Visibility.Visible;
        }

        void left_btn_Click(object sender, RoutedEventArgs e)
        {
            //throw new NotImplementedException();
        }

        void right_btn_Click(object sender, RoutedEventArgs e)
        {
            //throw new NotImplementedException();
        }

        internal Grid MainContainer
        {
            get { return main_container; }
        }
    }

    #endregion

}
